package com.boarsoft.flow.trace;

import java.io.Serializable;
import java.util.Date;
import java.util.Vector;

/**
 * 一个流程有一个主的FlowTrace<br>
 * 每个FlowTrace有一个堆栈<br>
 * 
 * 
 * @author Mac_J
 *
 */
public class SimpleFlowStep implements FlowStep, Serializable {
	private static final long serialVersionUID = -6919611676126239899L;
	/** 步骤编号 */
	protected String code;
	/** 线程号 */
	protected String threadName;
	/** 开始时间 */
	protected long startTime;
	/** 结束时间 */
	protected long endTime;
	/** */
	protected Vector<FlowTrace> traces = new Vector<FlowTrace>();
	/** */
	protected Object input;
	/** */
	protected Object output;

	public SimpleFlowStep(String code, Object input) {
		this.code = code;
		this.startTime = new Date().getTime();
		this.input = input;
		this.threadName = Thread.currentThread().getName();
	}

	@Override
	public void end(Object output) {
		this.endTime = new Date().getTime();
		this.output = output;
	}

	@Override
	public String getCode() {
		return code;
	}

	@Override
	public void setCode(String code) {
		this.code = code;
	}

	@Override
	public long getStartTime() {
		return startTime;
	}

	@Override
	public void setStartTime(long startTime) {
		this.startTime = startTime;
	}

	@Override
	public long getEndTime() {
		return endTime;
	}

	@Override
	public void setEndTime(long endTime) {
		this.endTime = endTime;
	}

	@Override
	public Vector<FlowTrace> getTraces() {
		return traces;
	}

	@Override
	public void setTraces(Vector<FlowTrace> traces) {
		this.traces = traces;
	}

	@Override
	public Object getInput() {
		return input;
	}

	@Override
	public void setInput(Object input) {
		this.input = input;
	}

	@Override
	public Object getOutput() {
		return output;
	}

	@Override
	public void setOutput(Object output) {
		this.output = output;
	}

	@Override
	public String getThreadName() {
		return threadName;
	}

	@Override
	public void setThreadName(String threadName) {
		this.threadName = threadName;
	}
}
